

namespace Patterns4Net.Core.Patterns
{
    using Mono.Cecil;
    using Attributes;
    using Attributes.DesignPatterns;
    using AttributesPatterns;

    [Immutable]
    public class Decorator : PatternBase, IWrapper
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="Decorator"/> class.
        /// </summary>
        /// <param name="dummyParameter">The dummy parameter is required by <see cref="WrapperCreator{TWrapper}"/>.</param>
        public Decorator(TypeDefinition decoratorType, TypeReference decoratedType, TypeReference dummyParameter)
        {
            this.DecoratorType = decoratorType;
            this.DecoratedType = decoratedType;
        }

        public TypeDefinition DecoratorType { get; private set; }

        [PatternRole(Name = "Decorated", RelationType = RelationType.Composition)]
        public TypeReference DecoratedType { get; private set; }


        #region IWrapper Members

        TypeReference IWrapper.WrappedType
        {
            get { return this.DecoratedType; }
        }

        /// <summary>
        /// Gets the target interface that the <see cref="WrapperType"/> implements.
        /// Decorator should as well implement the decorated interface.
        /// </summary>
        TypeReference IWrapper.TargetInterface
        {
            get { return this.DecoratedType; }
        }

        TypeDefinition IWrapper.WrapperType
        {
            get { return this.DecoratorType; }
        }

        #endregion
    }
}
